Skip to content

Pueblo/MXP HTML entity decoding (+ quote-aware tag scan) - #6

Merged
HarryCordewener merged 1 commit into
masterfrom
feat/pueblo-html-entities
Jun 30, 2026
Merged

Pueblo/MXP HTML entity decoding (+ quote-aware tag scan)#6
HarryCordewener merged 1 commit into
masterfrom
feat/pueblo-html-entities

Conversation

@HarryCordewener

Copy link
Copy Markdown
Member

What

Pueblo HTML mode entity-encodes reserved characters — a literal > arrives from the server as >. We were rendering entities verbatim. AnsiParser now decodes HTML entities, only inside markup mode (Pueblo active, or MXP active and not Locked); in plain ANSI output & stays literal.

Based on the Pueblo reference client (uecasm/pueblo) and BeipMU (BeipDev/BeipMU, src/TextToLine.cpp) entity/tag behavior.

Decoder

  • Named: < > & " '   © ® ™ (case-insensitive — friendlier than the reference client).
  • Numeric: &#NN; decimal and &#xNN; hex → full Unicode (we're UTF-8, so no 8-bit cast).
  • Robustness: a terminating ; is required; a lone or unrecognized & is emitted literally and never dropped; control-range (< U+0020), out-of-range, and surrogate code points are ignored (per MXP).
  • Attributes: xch_cmd / href / hint / … values are entity-decoded too.

Also

Made the tag-terminator scan quote-aware, so a literal > inside a quoted attribute value (e.g. <a xch_cmd="say 5 > 3">) no longer truncates the tag — a sturdiness guard the Pueblo reference client also has.

Tests

PuebloEntityTests (10): core entities, apos/nbsp, decimal+hex numeric, control-range ignore, lone/unknown & pass-through, markup-gating (no decode in plain mode), MXP decoding, attribute decoding, and raw->-in-attribute. Full suite 192/192, 0 warnings.

Independent of #5 (this branch is off master; #5 doesn't touch AnsiParser).

🤖 Generated with Claude Code

In Pueblo HTML mode the server entity-encodes reserved characters (a literal
'>' arrives as "&gt;"), so the client must decode them on render — previously
entities were shown verbatim. AnsiParser now decodes entities, but only inside
markup mode (Pueblo active, or MXP active and not Locked); in plain ANSI output
'&' stays literal.

Decoder (per the Pueblo reference client + BeipMU behaviour):
- named: &lt; &gt; &amp; &quot; &apos; &nbsp; &copy; &reg; &trade; (case-insensitive)
- numeric &#NN; decimal and &#xNN; hex, decoded to full Unicode (we're UTF-8)
- control-range (< U+0020), out-of-range and surrogate code points are ignored
- a terminating ';' is required; a lone or unrecognised '&' is emitted literally
  and never dropped
- attribute values (xch_cmd/href/hint/...) are entity-decoded too

Also made the tag-terminator scan quote-aware so a literal '>' inside a quoted
attribute value (e.g. <a xch_cmd="say 5 > 3">) no longer truncates the tag.

Tests: PuebloEntityTests (10) cover core/apos/nbsp, decimal+hex numeric, control
ignore, lone/unknown '&' pass-through, markup-gating, MXP decoding, attribute
decoding, and the raw-'>'-in-attribute case. Full suite 192/192, 0 warnings.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HHCRc5CJ6595iMzEgYYdQp
@HarryCordewener
HarryCordewener merged commit 3374a5c into master Jun 30, 2026
2 checks passed
@HarryCordewener
HarryCordewener deleted the feat/pueblo-html-entities branch July 6, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant